package com.book.controller;


import com.book.pojo.CollectRanking;
import com.book.result.Result;
import com.book.service.CollectRankingService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cxy
 * @since 2023-10-13 18:30:46
 */
@RestController
@RequestMapping("/collect-ranking")
public class CollectRankingController {

    @Autowired
    private CollectRankingService collectRankingService;

    //收藏榜表
    @GetMapping("CollectRanking")
    public Result CollectRanking (){
        List<CollectRanking> list=collectRankingService.CollectRanking();
        return Result.OK().setData(list);
    }
    //根据书id删除这本书的排行榜信息
    @DeleteMapping("deleteBybid")
    public void deleteBybid(@RequestParam Long bid) {
        collectRankingService.deleteBybid(bid);
    }

    //增加这本书的排行榜信息
    @PostMapping("addCollectRanking")
    public void addCollectRanking(@RequestBody CollectRanking collectRanking) {
        collectRankingService.addCollectRanking(collectRanking);
    }
}
